//-----------------------------------------------------------------------
// <copyright file="a_ArticleService.cs" company="AACECOM">
//     Copyright (c) AACECOM. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Collections;
using ThoiTrang.Entities;
using ThoiTrang.Data;
    
namespace ThoiTrang.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class a_ArticleService
    {
        #region a_Article

        public static void Createa_Article(a_Article a_Article)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                a_ArticleDAO.Createa_Article(a_Article);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void Updatea_Article(a_Article a_Article)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                a_ArticleDAO.Updatea_Article(a_Article);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void Deletea_Article(int id)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                a_ArticleDAO.Deletea_Article(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static a_Article Geta_Article(int id)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.Geta_Article(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static a_ArticleCollection Geta_ArticleList(a_ArticleColumns orderBy, OrderDirection orderDirection)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.Geta_ArticleList(orderBy, orderDirection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static a_ArticleCollection Geta_ArticleList(a_ArticleColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.Geta_ArticleList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion


        /******************************************************************************
        **	    Nguyen Minh Duc
        *******************************************************************************/
        public static int[] Geta_ArticleListYear(int scid)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.Geta_ArticleListYear(scid);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static a_ArticleCollection Geta_ArticleListNewer(int SubCat, int IdItem, a_ArticleColumns orderBy, OrderDirection orderDirection, int page, int pageSize)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.Geta_ArticleListNewer(SubCat, IdItem, orderBy, orderDirection, page, pageSize);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static a_ArticleCollection a_Articles_selListLaster(int SubCat, int IdItem, a_ArticleColumns orderBy, OrderDirection orderDirection, int page, int pageSize)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.a_Articles_selListLaster(SubCat, IdItem, orderBy, orderDirection, page, pageSize);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static a_ArticleCollection a_Articles_selListFavBySSID(string ssid, a_ArticleColumns orderBy, OrderDirection orderDirection)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.a_Articles_selListFavBySSID(ssid, orderBy, orderDirection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static a_ArticleCollection a_Articles_selListFavBySSID(string ssid, a_ArticleColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.a_Articles_selListFavBySSID(ssid, orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /******************************************************************************
        **	    End Nguyen Minh Duc
        *******************************************************************************/


        public static a_ArticleCollection Geta_ArticleListBySubIdAndMainId(int mainId, int subId, a_ArticleColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.Geta_ArticleListBySubIdAndMainId(mainId, subId, orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static a_ArticleCollection Geta_ArticleListByAll(int mainId, int subId, string fCountry, string fYear, string fkSeason, string permission, string keyword, a_ArticleColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.Geta_ArticleListByAll(mainId, subId, fCountry, fYear, fkSeason, permission, keyword, orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// badpaybad 
        /// </summary>
        /// <param name="mainId"></param>
        /// <param name="subId"></param>
        /// <param name="fCountry"></param>
        /// <param name="fYear"></param>
        /// <param name="fkSeason"></param>
        /// <param name="permission"></param>
        /// <param name="keyword"></param>
        /// <param name="orderBy"></param>
        /// <param name="orderDirection"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRecords"></param>
        /// <param name="dateFrom"></param>
        /// <param name="dateTo"></param>
        /// <param name="publicStatus"></param>
        /// <returns></returns>
        public static a_ArticleCollection Geta_ArticleListByCondition(int mainId, int subId, string fCountry, string fYear, string fkSeason, string permission, string keyword, a_ArticleColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords
            , string dateFrom, string dateTo, int publicStatus, int featuredType)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.Geta_ArticleListByCondition(mainId, subId, fCountry, fYear, fkSeason, permission, keyword, orderBy, orderDirection,
                   dateFrom, dateTo, publicStatus, featuredType,
                   page, pageSize, out totalRecords);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Nguyen Phan Du 2009 03 05
        /// </summary>
        /// <param name="CookieID"></param>
        /// <param name="AccessLevel"></param>
        /// <param name="isFeatured"></param>
        /// <param name="Status"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageSetSize"></param>
        /// <param name="sField"></param>
        /// <param name="sValue"></param>
        /// <param name="fDateFrom"></param>
        /// <param name="fDateTo"></param>
        /// <param name="SortBy"></param>
        /// <param name="SortOrder"></param>
        /// <param name="pgNum"></param>
        /// <param name="fCatID"></param>
        /// <param name="fSubCatID"></param>
        /// <returns></returns>
        public static System.Data.DataSet Get_Articles_selListByConditionAmdin(
                string CookieID,
                int AccessLevel,
                string isFeatured,
                string Status,
                int PageSize,
                int PageSetSize,
                string sField,
                string sValue,
                string fDateFrom,
                string fDateTo,
                string SortBy,
                string SortOrder,
                int pgNum,
                string fCatID,
                string fSubCatID
            )
        {
            //try
            //{
            a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
            return a_ArticleDAO.Get_Articles_selListByConditionAmdin(
            CookieID,
            AccessLevel,
            isFeatured,
            Status,
            PageSize,
            PageSetSize,
            sField,
            sValue,
            fDateFrom,
            fDateTo,
            SortBy,
            SortOrder,
            pgNum,
            fCatID,
            fSubCatID
                );
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
        //Get_articleFeaturedUpload


        public static System.Data.DataSet Get_articleFeaturedUpload()
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.Get_articleFeaturedUpload();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        //a_articleUploadDet_up
        public static System.Data.DataSet a_articleUploadDet_up(
              string Action,
             int AID,
             string Title,
             string CountryID,
             int fYear,
             int SeasonID,
             int WTypeID,
             int SexID,
             string Keywords,
             string ImgOri,
             string ImageW,
             int IID
            )
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.a_articleUploadDet_up(
                          Action,
                          AID,
                          Title,
                          CountryID,
                          fYear,
                          SeasonID,
                          WTypeID,
                          SexID,
                          Keywords,
                          ImgOri,
                          ImageW,
                          IID
                    );
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        //a_articleUploadDet_up
        public static System.Data.DataSet a_StatReport_Images(
              string DateTo,
             string DateFrom,
             string SortBy,
             string OrderBy,
             string Top,
             string DocType,
             int pgNum,
             int PageSize,
             int PageSetSize
            )
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.a_StatReport_Images(
                      DateTo,
                      DateFrom,
                      SortBy,
                      OrderBy,
                      Top,
                      DocType,
                      pgNum,
                      PageSize,
                      PageSetSize
                    );
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        //a_Article_RSS_allsite
        public static System.Data.DataSet a_Article_RSS_allsite()
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.a_Article_RSS_allsite();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //a_Article_RSS
        public static System.Data.DataSet a_Article_RSS(
            int TypeCat,
             string CatID,
             string NumTop)
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.a_Article_RSS(
                     TypeCat,
                     CatID,
                     NumTop
                    );
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static System.Data.DataSet a_StatReport_Articles(
              string DateTo,
            string DateFrom,
            string SortBy,
            string OrderBy,
            string Top,
            string DocType,
            int pgNum,
            int PageSize,
            int PageSetSize
       )
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.a_StatReport_Articles(
              DateTo,
            DateFrom,
            SortBy,
            OrderBy,
            Top,
            DocType,
            pgNum,
            PageSize,
            PageSetSize
                    );
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static System.Data.DataSet a_adm_stats_sel(
           string sField,
         string sValue,
         string SortBy,
         string OrderBy,
         int pgNum,
         int PageSize,
         int PageSetSize
     )
        {
            a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
            return a_ArticleDAO.a_adm_stats_sel(
             sField,
          sValue,
          SortBy,
          OrderBy,
          pgNum,
          PageSize,
          PageSetSize
                );
        }

        public static System.Data.DataSet a_adm_stats_det_sel(
        string RefID,
int PageSize,
int PageSetSize,
int typeDate, 				//-- 0: filter rangeDate			1: filter by specify date form and date to
string rangeDate,
string fDateFrom,
string fDateTo,
string SortBy,
string SortOrder,
int pgNum
      )
        {
            a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
            return a_ArticleDAO.a_adm_stats_det_sel(
              RefID,
 PageSize,
 PageSetSize,
 typeDate, 				//-- 0: filter rangeDate			1: filter by specify date form and date to
 rangeDate,
 fDateFrom,
 fDateTo,
 SortBy,
 SortOrder,
 pgNum
                );
        }

        public static a_ArticleCollection GetFeaturedArticles()
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.GetFeaturedArticles();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static a_ArticleCollection GetLastestArticles()
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.GetLastestArticles();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static a_ArticleCollection GetRecruitmentArticles()
        {
            try
            {
                a_ArticleDAO a_ArticleDAO = new a_ArticleDAO();
                return a_ArticleDAO.GetRecruitmentArticles();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    }
}